package com.caiwangdai.app.ui.borrow.adapter

import android.app.Activity
import android.graphics.Color
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.TextView
import com.caiwangdai.app.R
import kotlinx.android.synthetic.main.custom_spinner_dropdown_item.view.*

//Spinner的适配器
class BorrowIntentAdapter : BaseAdapter {
    private var mDataList = mutableListOf<String>()
    private var mActivity: Activity? = null

    constructor(mActivity: Activity?,mDataList: MutableList<String>) : super() {
        this.mDataList = mDataList
        this.mActivity = mActivity
    }


    override fun getItem(position: Int) = mDataList[position]

    override fun getItemId(position: Int): Long = position.toLong()

    override fun getCount() = mDataList.size

    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var holder: ViewHolder
        var v: View
        if (convertView == null) {
            v = View.inflate(mActivity, R.layout.custom_spinner_dropdown_item, null)
            holder = ViewHolder(v)
            v.tag = holder
        } else {
            v = convertView
            holder = v.tag as ViewHolder
        }
        holder.str.text = mDataList[position]
//        if (position==0){
//            with(holder.str){
//                this.textSize=14f
//                this.setTextColor(Color.rgb(223,224,225))
//            }
//        }else{
//            with(holder.str){
//                this.textSize=23f
//                this.setTextColor(Color.rgb(13,13,13))
//            }
//        }

        with(holder.str){
            this.textSize=23f
            this.setTextColor(Color.rgb(13,13,13))
        }
        return v
    }

    class ViewHolder(var viewItem: View) {
        var str: TextView = viewItem.tv_title
    }
}